from django.db import models

class UserModel(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=255)
    class Meta:
        db_table = "user_tb"
        verbose_name = "用户"
        verbose_name_plural = verbose_name


class RoleModel(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=255)
    users = models.ManyToManyField(to=UserModel, related_name="roles", db_constraint=False, blank=True)
    powers = models.ManyToManyField(to="PowerModel", related_name="roles", db_constraint=False, blank=True)

    class Meta:
        db_table = "role_tb"
        verbose_name = "角色"
        verbose_name_plural = verbose_name

class PowerModel(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=255)
    class Meta:
        db_table = "power_tb"
        verbose_name = "权限"
        verbose_name_plural = verbose_name